

import {getsong,fm,getList} from '../../My/api/index'
import {action,observable,runInAction} from 'mobx'
// import{SerachSong} from "../api/index"

class My {
    @observable arr=[{album:{
        name:"",
        picUrl:"",
    }}]
    @observable url=['','','','','','']
    @action.bound getfm(){
        let that=this
        fm().then(res=>{
            runInAction(function(){
                that.arr=res.data
                let i=0
                res.data.forEach(item=>{
                    getsong(item.album.id).then(res=>{
                        console.log(res.data[0].url,'==============');
                        that.url[i]=res.data[0].url;
                        i++;
                    })
                })
            })
        })
    }
    @action.bound getmusic(id){
        let that =this;
        getsong(id).then(res=>{
            runInAction(function(){
                console.log(res,'++++++++++++++++++==');
            })
        })
    }
    constructor(root){
        this.RootStore=root
    }

//     @observable @observable song=[{albums:{
//             name:""
//     }}]

//     @action.bound  Change( value){
//         console.log(value);
//         const _this = this;
//         SerachSong(value)
//             .then(res => {
//                 runInAction(function ( ) {//处理异步请求
//                     _this.song= res;
//                     console.log(_this.song.result.albums)
//                 })
//             })
//     }

}

export default My